package net.sansi.v3correctserver.config.converter;

import com.dtflys.forest.converter.json.ForestJacksonConverter;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

/**
 * 自定义一个Protobuf的转换器，并实现ForestConverter接口下的convertToJavaObject方法
 * 这个类主要给 forest 框架使用
 * forest 框架中没有默认使用 Springboot 的 ObjectMap, 因此导致无法解析 LocalDateTime
 */
public class MyJacksonConverter extends ForestJacksonConverter {
    public MyJacksonConverter() {
        this.mapper.registerModule(new JavaTimeModule());
        this.mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        this.mapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false);
    }
}